package com.xhdx.bussi;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Test2 {
    public void loanCalculateReward() {
        System.out.println("---开始---");
        SeqLoanOrder y1 = new SeqLoanOrder();
        y1.setLoanActualSum(new BigDecimal(4000000));
        y1.setIsBangkClerk(1);
        y1.setCustomerManagerId(111111111l);
        
        SeqLoanOrder y2 = new SeqLoanOrder();
        y2.setLoanActualSum(new BigDecimal(4000000));
        y2.setIsBangkClerk(3);
        y2.setCustomerManagerId(22222222222222l);
        
        SeqLoanOrder y3 = new SeqLoanOrder();
        y3.setLoanActualSum(new BigDecimal(4000000));
        y3.setIsBangkClerk(2);
        y3.setCustomerManagerId(333333333333333l);
        
        SeqLoanOrder y4 = new SeqLoanOrder();
        y4.setLoanActualSum(new BigDecimal(800000));
        y4.setIsBangkClerk(1);
        y4.setCustomerManagerId(444l);
        
        SeqLoanOrder y5 = new SeqLoanOrder();
        y5.setLoanActualSum(new BigDecimal(320000));
        y5.setIsBangkClerk(2);
        y5.setCustomerManagerId(555l);
        
        SeqLoanOrder y6 = new SeqLoanOrder();
        y6.setLoanActualSum(new BigDecimal(5000000));
        y6.setIsBangkClerk(1);
        y6.setCustomerManagerId(111111111l);
        
        SeqLoanOrder y7 = new SeqLoanOrder();
        y7.setLoanActualSum(new BigDecimal(8000000));
        y7.setIsBangkClerk(2);
        //y7.setCustomerManagerId(111111111l);
        
        SeqLoanOrder y8 = new SeqLoanOrder();
        y8.setLoanActualSum(new BigDecimal(2500000));
        y8.setIsBangkClerk(1);
        y8.setCustomerManagerId(111111111l);
        
        SeqLoanOrder y9 = new SeqLoanOrder();
        y9.setLoanActualSum(new BigDecimal(2490000));
        y9.setIsBangkClerk(1);
        y9.setCustomerManagerId(111111111l);
        
        SeqLoanOrder y10 = new SeqLoanOrder();
        y10.setLoanActualSum(new BigDecimal(2510000));
        y10.setIsBangkClerk(2);
        y10.setCustomerManagerId(111111111l);
        
        List<SeqLoanOrder> loanOrderList = new ArrayList<SeqLoanOrder>();
        loanOrderList.add(y1);
        loanOrderList.add(y2);
        loanOrderList.add(y3);
        loanOrderList.add(y4);
        loanOrderList.add(y5);
        loanOrderList.add(y6);
        loanOrderList.add(y7);
        loanOrderList.add(y8);
        loanOrderList.add(y9);
        loanOrderList.add(y10);
        
        if(loanOrderList != null && loanOrderList.size() > 0){
            BigDecimal rate = new BigDecimal(0.0002f);
            BigDecimal maxRewad1 = new BigDecimal(500);
            loanOrderList.forEach(loanOrder ->{
                BigDecimal loanActualSum = loanOrder.getLoanActualSum();
                BigDecimal markRewarAmt = BigDecimal.ZERO;
                if(loanActualSum.compareTo(new BigDecimal(2500000))>=0){
                    markRewarAmt = maxRewad1;
                }else if(loanActualSum.compareTo(BigDecimal.ZERO)>0){
                    markRewarAmt = loanActualSum.multiply(rate);
                }else{
                    markRewarAmt = BigDecimal.ZERO;
                }
                markRewarAmt=markRewarAmt.setScale(2, BigDecimal.ROUND_HALF_UP);
                loanOrder.setMarkRewarAmt(markRewarAmt);
                if(loanOrder.getCustomerManagerId() != null){
                    if(2 == loanOrder.getIsBangkClerk()){
                        loanOrder.setRewarAmt(markRewarAmt.multiply(new BigDecimal(0.7)).setScale(2, BigDecimal.ROUND_HALF_UP));
                        loanOrder.setExtraRewarAmt(markRewarAmt.subtract(loanOrder.getRewarAmt()));
                    }else{
                        loanOrder.setRewarAmt(markRewarAmt);
                        loanOrder.setExtraRewarAmt(BigDecimal.ZERO);
                    }
                    
                }else{
                    loanOrder.setRewarAmt(BigDecimal.ZERO);
                    loanOrder.setExtraRewarAmt(BigDecimal.ZERO);
                }
                loanOrder.setCalculate(1);
                System.out.println(loanOrder.toString());
            });
        }
        System.out.println("---结束---");
    }
    public static void main(String[] args) {
        Test2 t = new Test2();
        t.loanCalculateReward();
    }
}
